import java.util.*;

/**
 * @author LKQ
 * @date 2022/5/2 20:50
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.countNicePairs(new int[] {42, 11, 1, 97});
    }
    public int countNicePairs(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        long ans = 0;
        int mod = (int) (1e9 + 7);
        for (int num: nums) {
            int k = rev(num) - num;
            if (map.containsKey(k)) {
                ans = (ans + map.get(k)) % mod;
            }
            map.put(k, map.getOrDefault(k, 0) + 1);
        }
        return (int) ans;
    }

    public int rev(int n) {
        int ans = 0;
        while (n != 0) {
            ans = ans * 10 + n % 10;
            n /= 10;
        }
        return ans;
    }
}
